package com.dogkr.server.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class PetServer {
	//基础服务CODE
	public static String BASE_SERVER_CODE = "base";
	
	private Long id;

	private Long hostId;

	private String serverCode;

	private String serverName;
	
	private Short valueType;

	private Date lastModifydate;

	private Date createDate;

	private Short status;

	private String remark;

	private List<PetServerRestrain> petServerRestrainList;

	private List<PetServerValuation> petServerValuationList;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getHostId() {
		return hostId;
	}

	public void setHostId(Long hostId) {
		this.hostId = hostId;
	}

	public String getServerCode() {
		return serverCode;
	}

	public void setServerCode(String serverCode) {
		this.serverCode = serverCode;
	}

	public String getServerName() {
		return serverName;
	}

	public void setServerName(String serverName) {
		this.serverName = serverName;
	}

	public Date getLastModifydate() {
		return lastModifydate;
	}

	public void setLastModifydate(Date lastModifydate) {
		this.lastModifydate = lastModifydate;
	}

	public Short getValueType() {
		return valueType;
	}

	public void setValueType(Short valueType) {
		this.valueType = valueType;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Short getStatus() {
		return status;
	}

	public void setStatus(Short status) {
		this.status = status;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
    
    public ValueTypeEnum getValueTypeEnum() {
		return ValueTypeEnum.valueOf(this.valueType);
	}

	public void setValueTypeEnum(ValueTypeEnum valueTypeEnum) {
		if(valueTypeEnum == null) {
			this.valueType = null;
		} else {
			this.valueType = valueTypeEnum.getVal();
		}
	}

	public List<PetServerRestrain> getPetServerRestrainList() {
		return petServerRestrainList;
	}

	public void setPetServerRestrainList(
			List<PetServerRestrain> petServerRestrainList) {
		this.petServerRestrainList = petServerRestrainList;
	}

	public List<PetServerValuation> getPetServerValuationList() {
		return petServerValuationList;
	}

	public void setPetServerValuationList(
			List<PetServerValuation> petServerValuationList) {
		this.petServerValuationList = petServerValuationList;
	}

	public enum ValueTypeEnum {
    	/**
    	 * 天
    	 */
    	DAY((short)0),
    	/**
    	 * 次
    	 */
    	TIMES((short)1);
    	
    	private short val;
    	
    	ValueTypeEnum(short val) {
    		this.val = val;
    	}
    	
    	public static ValueTypeEnum valueOf(short val) {
    		for (ValueTypeEnum type : ValueTypeEnum.values()) {
				if(type.getVal() == val) {
					return type;
				}
			}
    		return null;
    	}
    	
		public short getVal() {
			return val;
		}
    }
	
	public enum RestrainTypeEnum {
    	/**
    	 * 距离
    	 */
		RANGE((short)0);
    	
    	private short val;
    	
    	RestrainTypeEnum(short val) {
    		this.val = val;
    	}

    	public static RestrainTypeEnum valueOf(short val) {
    		for (RestrainTypeEnum type : RestrainTypeEnum.values()) {
				if(type.getVal() == val) {
					return type;
				}
			}
    		return null;
    	}
    	
		public short getVal() {
			return val;
		}
    }

	public void addValuation(PetServerValuation valuation) {
		if(this.petServerValuationList == null) {
			this.petServerValuationList = new ArrayList<PetServerValuation>();
		}
		this.petServerValuationList.add(valuation);
	}
}